//
//  MyNavigationController.swift
//  SwiftLearningDemo
//
//  Created by ShareAnimation on 17/5/23.
//  Copyright © 2017年 爱丽丝的梦境. All rights reserved.
//

import UIKit
import SnapKit

class MyNavigationController: UINavigationController {
    
    var frostedView: UIToolbar = UIToolbar()

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.setup()
    }
    
    func setup() {
        
        self.navigationBar.setBackgroundImage(UIImage(), for: .default)// navigationBar透明，但是按钮还在
        self.navigationBar.shadowImage = UIImage()// 去掉横线
        
        let maskingView = UIView()
        maskingView.isUserInteractionEnabled = false
        maskingView.backgroundColor = UIColor.clear
        self.navigationBar.superview?.insertSubview(maskingView, belowSubview: self.navigationBar)//只作alpha变化效果的控件最好不要遮盖原本的控件，所以插入到它下面一层
        maskingView.snp.makeConstraints { (make) in
            make.left.bottom.right.equalTo(self.navigationBar)
            make.top.equalTo(self.navigationBar)
        }

        self.frostedView.alpha = 0
        self.frostedView.isUserInteractionEnabled = false
        self.frostedView.clipsToBounds = true
        maskingView.addSubview(self.frostedView)
        self.frostedView.snp.makeConstraints { (make) in
            make.edges.equalTo(maskingView)
        }
    }

}
